<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <!-- 引入样式 -->
    <link rel="stylesheet" type="text/css" href="/assets/element-plus/index.css">
    <!-- 引入组件库 -->
    <script src="/assets/vue/vue.global.js"></script>
    <script src="/assets/element-plus/index.full.js"></script>
    <script src="/assets/axios/axios.js"></script>

    <style>
        html, body {
            padding: 0px;
            margin: 0px;
        }
        .login_container {
            background-color: #2b4b6b;
            height: 100vh;
        }

        .login_box {
            width: 450px;
            height: 300px;
            background-color: #fff;
            border-radius: 3px;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);

            .el-avatar {
                height: 130px;
                width: 130px;
                border: 1px solid #eee;
                border-radius: 50%;
                padding: 10px;
                box-shadow: 0 0 10px #ddd;
                position: absolute;
                left: 50%;
                transform: translate(-50%, -50%);
                background-color: #fff;

                img {
                    width: 100%;
                    height: 100%;
                    border-radius: 50%;
                    background-color: #eee;
                }
            }
        }

        .login_form {
            position: absolute;
            bottom: 0;
            width: 100%;
            padding: 0 20px;
            box-sizing: border-box;
        }

        .login_btn {
            display: flex;
            justify-content: flex-end;
        }

        .input {
            font-size: 2em;
        }

        .center-text-input .el-input__inner {
            text-align: center;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="login_container">
        <div class="login_box">
            <!-- 登录表单区域 -->
            <el-form label-width="0px" class="login_form">
                <h1 style="text-align: center">数据管理中心</h1>
                <!-- 用户名 -->
                <el-form-item>
                    <el-input  class="input center-text-input" v-model="form.username" size="large" type="username"></el-input>
                </el-form-item>
                <!-- 密码 -->
                <el-form-item>
                    <el-input class="input center-text-input" v-model="form.password" size="large" type="password"></el-input>
                </el-form-item>
                <!-- 按钮区域 -->
                <el-row>
                    <el-button type="primary" @click="login" size="large" style="width: 100%;margin-bottom: 10px">登录</el-button>
                </el-row>
            </el-form>
        </div>
    </div>
</div>

<script>
    const Main = {
        data(){
            return{
                form:{
                    username : null,
                    password : null
                }
            }
        },
        methods : {
            login : function(){
                const app = this;
                const params = new URLSearchParams();
                params.append("username", app.form.username);
                params.append("password", app.form.password);
                axios.post("/authentication",params)
                    .then(function(response){
                        window.location.href = "/management/default.html";
                    })
                    .catch(function(ex){
                        ElementPlus.ElMessage.error({
                            message: ex.response.data .message
                        })
                    })
            }
        }
    };
    const app = Vue.createApp(Main);
    app.use(ElementPlus);
    app.mount("#app")
</script>

</body>
</html>